#include "../StdInc.h"

namespace GSTrader
{
	namespace TradeStrategy
	{
		CStrategyInstrument::CStrategyInstrument(CStrategyBase* pStrategy) : m_pStrategy(pStrategy)
		{
			m_vInstrumentId.reserve(30);
		}

		CStrategyInstrument::~CStrategyInstrument()
		{

		}

		void CStrategyInstrument::Clear()
		{
			m_vInstrumentId.clear();
		}

		bool CStrategyInstrument::Contains(int nId)
		{
			return find(m_vInstrumentId.begin(), m_vInstrumentId.end(), nId) != m_vInstrumentId.end();
		}

		bool CStrategyInstrument::Add(int nId)
		{
			if (nId < 0)
			{
				assert(false);
				return false;
			}

			if (Contains(nId))
			{
				return false;
			}
			else
			{
				m_vInstrumentId.push_back(nId);
			}

			return true;
		}

		bool CStrategyInstrument::Remove(int nId)
		{
			m_vInstrumentId.erase(remove(m_vInstrumentId.begin(), m_vInstrumentId.end(), nId), m_vInstrumentId.end());
			return true;
		}
	}
}